# Contributor: Vince Mele <vmele@inoc.com>
# Contributor: Henrik Riomar <henrik.riomar@gmail.com>
# Maintainer: Vince Mele <vmele@inoc.com>
pkgname=sssd
pkgver=2.9.3
pkgrel=2
pkgdesc="System Security Services Daemon"
url="https://github.com/SSSD/sssd"
arch="x86_64"
license="GPL-3.0-or-later"

# TODO: the full test suite depends on these
#	but does not pass.
#checkdepends="
#	check-dev
#	cmocka-dev
#	"

depends="
	bind
	curl
	cyrus-sasl-gssapiv2
	"
makedepends="
	autoconf
	automake
	bash
	bind-tools
	c-ares-dev
	cifs-utils-dev
	curl-dev
	dbus-dev
	ding-libs-dev
	docbook-xsl
	gettext-dev
	glib-dev
	http-parser-dev
	jansson-dev
	jose-dev
	keyutils-dev
	krb5-dev
	ldb-dev
	libtool
	libunistring-dev
	libxml2-utils
	libxslt
	linux-pam-dev
	musl-nscd-dev
	nss-dev
	openldap-dev
	p11-kit-dev
	pcre2-dev
	popt-dev
	py3-setuptools
	python3-dev
	talloc-dev
	tdb-dev
	tevent-dev
	"
subpackages="$pkgname-dev py3-$pkgname-pyc py3-$pkgname:py3 $pkgname-openrc"
source="https://github.com/SSSD/sssd/releases/download/$pkgver/sssd-$pkgver.tar.gz
	0001-makefile.patch
	musl_fixup.patch
	sssd.initd
	"

prepare() {
	default_prepare

	autoreconf -fvi
}

build() {
	./configure \
		--prefix=/usr \
		--sbindir=/usr/sbin \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--libexecdir=/usr/lib/sssd \
		--datadir=/usr/share \
		--with-pid-path=/run \
		--with-initscript=sysv \
		--with-init-dir=/etc/init.d \
		--disable-cifs-idmap-plugin \
		--disable-rpath \
		--disable-static \
		--without-autofs \
		--without-manpages \
		--without-nfsv4-idmapd-plugin \
		--without-python2-bindings \
		--without-samba \
		--without-selinux \
		--without-semanage \
		--without-ssh
	make
}

check() {
	make check
}

package() {
	make -j1 DESTDIR="$pkgdir" install

	install -Dm755 "$srcdir"/sssd.initd "$pkgdir"/etc/init.d/sssd

	# shellcheck disable=SC2115
	rm -r "$pkgdir"/usr/share
	rm -r "$pkgdir"/run
}

py3() {
	amove usr/lib/python*
}

sha512sums="
e1c3e107c98ac2cbc4f38e435910ebd560464773e7e93c8982db37d1ccdf78bc5e3f514bbcd2aaae54074ca6197b2067531180b83ee8c0e7f94878a824834a21  sssd-2.9.3.tar.gz
a62843c65d864fa372b7ed550bdd6f277f054f3efae941c48e9bab239758dad079886f26fbb06fe15310845ba8dc5126d108b06864712c88904b08847a032308  0001-makefile.patch
c9db51a773c821a2c5327d2e4b0d3c81dd89d780aa7f9dd66ff88a7419a8072907047c8d9faec17ea14c5404c636485eceda85df0b299f40fae362ef7bfb34e8  musl_fixup.patch
7198c66c96ba48c43def004e302be2e3348d43a4b5a1b35eb25f99081f1f6dce89d3994377a3064f72462509648bfbca1062493d244e413f0c47122cc0436bc9  sssd.initd
"
